home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 1
/
Cream of the Crop 1.iso
/
BUSINESS
/
SALE24.ARJ
/
REPORTER.SC
< prev
next >
Wrap
Text File
|
1992-05-02
|
12KB
|
476 lines
;******************************************
; REPORTER.SC
; Copyright (C) 1992 SHARED LOGIC, INC.
; ALL RIGHTS RESERVED.
; May be used if credit is given.
; Use at your own risk: the author makes
; no warranties nor guarantees.
; Author: Tim Colling
; Purpose: Script for the REPORTER()
; proc described in Data Based Advisor
; Magazine
;******************************************
lib_name = "paradox"
if not isfile(lib_name+".lib") then
createlib "paradox" size 300
endif
? "Compiling reporter() procs"
;******************************************
; reporter()
;******************************************
;Purpose: To permit the user to run a
; report, specifying the print style from
; a standard "config" table with such
; information.
proc reporter(
table2use, ;The table to report from
report2use, ;The report to be used
destination, ;Where to send the report
printstyle2use, ;Style selection, or As-Is
continuous, ;True=>Page Length = "c"
configTable, ;System configuration file
specialReportProc,;Special report proc name
filename.to.use) ;Name of file to create
private
setupstring, ;The printer setup string
linesperpage, ;The number of lines per page
printerport, ;The port to be used
family.rights,;True=>user has"R"tablerights
proc.name, ;This proc's name
old.margin, ;Report's orig margin setting
original.destination,;Dest in proc call
original.setup, ;Report's orig setup string
Choice ;Menu selection
proc.name="reporter"
original.destination = upper(destination)
while true
working_message("")
reporter.parm.checker()
if retval = false then
return false
endif
if isassigned(printerport) then
setprinter printerport
endif
working_message("Making final "+
"preparations for producing "+
"your output.")
if continuous then
linesperpage = "C"
endif
;Open up the report spec file
menu {report} {change}
select table2use
select report2use
enter
;Set the PRINTERPORT
;----------------------
menu
{setting} {setup} {custom}
select printerport
enter
;Set the SETUPSTRING
;and LINESPERPAGE values
;------------------------
if not printstyle2use = "AS-IS" then
menu {setting} {setup} {custom} enter
ctrlbackspace typein setupstring enter
menu {setting} {pagelayout} {length}
ctrlbackspace typein linesperpage
enter
endif
;Do any other custom work by
;calling the special report proc
;-------------------------------
if not isblank(specialReportProc) then
execproc specialReportProc
endif
working_message("Producing your output."+
" Press any key to interrupt.")
while true
switch
case destination = "PRINTER":
;----------------------------
open printer
menu {output} {printer}
if retval=1 then ;we must have
reset return false ;triggered the
endif ;errorproc
working_message("")
close printer
if original.destination = "OPTION" then
destination = "OPTION"
loop
endif
DoReportAgainMenu()
if retval then
loop
else
ExitChoice = true
quitloop
endif
case destination = "SCREEN":
;----------------------------
;Save the original margin
;and then set the margin
;to zero to maximize the
;amount of text displayed
;on the initial screen
;------------------------
menu {setting} {margin}
old.margin = menuchoice()
{0}
;Save the original setup string
;and then eliminate it so that
;it doesn't clutter up the
;screen display
;------------------------------
menu {setting} {setup} {custom}
enter
old.setup = menuchoice()
ctrlbackspace
enter
;Send the report to a file
;-------------------------
menu {output} {file}
select privdir()+"report.t"
if menuchoice()="Cancel" then
{Replace}
endif
;Use README.COM to display the file
;----------------------------------
run "readme "+privdir()+"report.t"
if retval=1 then ;we must have
reset return false ;triggered the
endif ;errorproc
working_message("")
run norefresh "del "+privdir()+"report.t"
;Restore original margin
;------------------------
menu {setting} {margin}
select old.margin
;Restore original setup string
;-----------------------------
menu {setting} {setup}
{custom} enter
select old.setup
if original.destination = "OPTION" then
destination = "OPTION"
loop
endif
DoReportAgainMenu()
if retval then
loop
else
ExitChoice = true
quitloop
endif
case destination = "FILE":
;----------------------------
menu {output} {file}
select privdir()+filename.to.use
if menuchoice()="Cancel" then
{Replace}
endif
if retval=1 then ;we must have
reset return false ;triggered the
endif ;errorproc
working_message("")
if original.destination = "OPTION" then
destination = "OPTION"
loop
endif
DoReportAgainMenu()
if retval then
loop
else
ExitChoice = true
quitloop
endif
case destination = "OPTION":
;----------------------------
showmenu
"Printer":
"Send the report to your Printer",
"Screen":
"Send the report to your Screen",
"File":
"Send the report to a File "+
"in your private directory",
"Done":
"Done with this report job"
to destination
working_message("")
if not retval then
;User pressed Esc,
;therefore we are DONE
;--------------------
destination = "DONE"
endif
destination = upper(destination)
switch
case destination = "PRINTER":
ExitChoice = false
quitloop
case destination = "FILE":
while true
@ 1,0 clear eol
@ 0,0 clear eol
cursor normal
@ 1,0 ?? "File Extension must be "+
"either TXT, RPT, DOC, PRN"
@ 0,0 ?? "Please enter the filename :"
accept "A12"
picture
"&{*7[&,#,_]}.{TXT,DOC,PRN,RPT}"
to filename.to.use
if not retval then
destination = "OPTION"
quitloop
endif
cursor off
working_message("")
if isfile(privdir()+
filename.to.use) then
showmenu
"No":
"Do NOT Overwrite existing File",
"Yes":
"Overwrite existing File"
to Choice
switch
case Choice = "No" : loop
case Choice = "Yes": quitloop
endswitch
endif
quitloop
endwhile
loop
case destination = "SCREEN":
working_message("")
loop
case destination = "DONE":
ExitChoice = true
quitloop
endswitch
endswitch
endwhile
{cancel} {yes}
if ExitChoice then
quitloop
else
loop
endif
endwhile
return true
endproc
writelib lib_name reporter
release procs reporter
?? "."
;******************************************
; reporter.parm.checker()
;******************************************
;Purpose: checks the parameters used with
; the reporter() proc
proc reporter.parm.checker()
private proc.name
proc.name = "reporter.parm.checker"
if isempty( table2use ) then
error_message(
"Sorry, the table \"" + table2use +
"\" is empty. There is nothing to report.",
"Press any key to continue.",500)
return false
endif
destination = upper( destination )
printstyle2use = upper( printstyle2use )
if destination <> "PRINTER" and
destination <> "SCREEN" and
destination <> "FILE" and
destination <> "OPTION" then
error_message(
"Sorry, an incorrect report destination "+
"is specified in this program.",
"Press any key to continue." ,500)
return false
endif
if printstyle2use <> "10-PITCH" and
printstyle2use <> "CONDENSED" and
printstyle2use <> "AS-IS" then
error_message(
"Sorry, an incorrect print style is "+
"specified in this program.",
"Press any key to continue." ,500)
return false
endif
if type(continuous)<> "L" then
error_message(
"Sorry, an incorrect \"continuous\" "+
"argument is specified in "+
"this program.",
"Press any key to continue.",500)
return false
endif
;The ConfigTable is essential to this
;proc and cannot be done without
;--------------------------------------
if not istable( configtable ) then
error_message(
"Error: there is no \"config\" table. "+
"The output is cancelled.",
"Please advise your system administrator."+
" Press any key to go on.",500)
return false
endif
;Get the setup string, pagelength and
;printer to be used
;--------------------------------------
view configtable
switch
case printstyle2use = "10-PITCH" :
setupstring = [Printer setup - 10 pitch]
linesperpage = [Lines per pg - 10 pitch]
printerport = [Printer port]
case printstyle2use = "CONDENSED" :
setupstring = [Printer setup - condensed]
linesperpage = [Lines per pg - condensed]
printerport = [Printer port]
case printstyle2use = "AS-IS" :
printerport = [Printer port]
endswitch
clearimage
family.rights =
familyrights( table2use, "R" )
if family.rights = false then
error_message(
"ENCRYPTION ERROR: Family Rights must "+
"include \"R\" for table " +
table2use + ".",
"Contact your System Supervisor for "+
"assistance. Press any key to continue.",
500)
return false
endif
return true
endproc
writelib lib_name reporter.parm.checker
release procs reporter.parm.checker
?? "."
;******************************************
; working_message()
;******************************************
;Purpose: puts up working message with
; optional second line
proc working_message(txt)
private proc.name
proc.name = "working_message"
@ 1,0 clear eol ?? txt
@ 0,0 clear eol ?? "Working"
style blink ?? "..."
style cursor off
endproc
?? "." writelib lib_name working_message
release procs working_message
;******************************************
; error_message()
;******************************************
;Purpose: presents an error message to the
; user and waits for a keypress
proc error_message(
txt1, ;Text to place on line 1
txt2, ;Text to place on line 2
duration ) ;interval between beeps
private proc.name
proc.name = "error_message"
@ 1,0 clear eol ?? txt2
@ 0,0 clear eol ?? txt1
cursor off
beep
while charwaiting()
retval = getchar()
endwhile
;If duration is 0, then don't beep
; anymore. Otherwise, use duration
; as the sleep interval between beeps
;------------------------------------
while duration <> 0 and not charwaiting()
beep
sleep duration
endwhile
return getchar()
endproc
proc.name = "error_message"
writelib lib_name error_message
release procs error_message
;******************************************
; DoReportAgainMenu()
;******************************************
;Purpose: Ask the user whether to
; reprint a report that has just been
; printed. Returns true if user selects
; "Do-Again", otherwise returns false.
; Checks for charwaiting() to avoid any
; typing ahead
proc DoReportAgainMenu()
private proc.name, choice
proc.name = "DoReportAgainMenu"
while charwaiting()
choice = getchar()
endwhile
while true
showmenu
"DoAgain" : "Repeat the output process.",
"Finished": "Finished with output. Okay to return."
to choice
working_message("")
if choice = "Esc" Or choice = "Finished" then
return false
else
return true
endif
endwhile
endproc
writelib lib_name DoReportAgainMenu
release procs DoReportAgainMenu
?? "."